package com.yonyou.brigade.facade.model;

import com.alibaba.fastjson.JSONObject;
import com.yonyou.brigade.basic_init.model.BriChannel;
import com.yonyou.brigade.basic_init.model.RefModel;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * 开通信息数据传输模型
 *
 * @author kangfw5
 * @date 2019/2/26 12:51
 */
public class ChannelDTO implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 租户ID
     */
    @NotBlank(message = "租户不能为空")
    private String tenantId;
    /**
     * 组织
     */
    private List<RefModel> orgs;
    /**
     * 渠道code
     */
    @NotBlank(message = "开通商旅服务渠道不能为空")
    private String channel;
    /**
     * 配置信息
     */
    @NotNull(message = "商旅提供商配置信息不能为空")
    private Map config;

    /**
     * 是否启用提前审批 0否 1 开启 默认0
     */
    private Integer isPreApprove;
    /**
     * 联系人手机号
     */
    @NotBlank(message = "租户管理员手机号不能为空")
    private String adminPhone;
    /**
     * 开通类型 1按照租户开通  2按照组织开通
     */
    @Range(min = 1, max = 2, message = "商旅服务开通类型错误")
    @NotNull(message = "商旅服务开通类型错误")
    private Integer openType;
    /**
     * 是否向第三方商旅平台同步人员 0否 1 开启
     */
    private Integer syncUser;
    /**
     * 组织部门同步 0 不同步 1 同步
     */
    private Integer syncOrgDept;
    /**
     * 组织部门同步 0 不同步 1 同步
     */
    private Integer syncRank;
    /**
     * 单点登录标识 1 员工号 2 手机号 3 身份证号
     */
    private Integer ssoKey;
    /**
     * 费用归属信息同步 0 不同步 1 名称 2 编号
     */
    private Integer syncCostInfo;
    /**
     * 行程出发城市控制 0 不控制 1 控制
     */
    private Integer fromCityControl;
    /**
     * 预定弹性天数
     */
    private Integer bookElasticDay;
    /**
     * 申请单职级二次传参 0 不传 1 预订人 2 申请人
     */
    private Integer rankSecondPass;
    /**
     * 当天往返不可住宿 0 否 1 是
     */
    private Integer noHotelOneDay;
    /**
     * 住宿城市入住策略 0 不限 1 所有途径城市 2 所有途径目的地城市
     */
    private Integer hotelCityStrategy;
    public final static String IS_PRE_APPROVE = "isPreApprove";

    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    public List<RefModel> getOrgs() {
        return orgs;
    }

    public void setOrgs(List<RefModel> orgs) {
        this.orgs = orgs;
    }

    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    public Map getConfig() {
        return config;
    }

    public void setConfig(Map config) {
        this.config = config;
    }

    public Integer getIsPreApprove() {
        return isPreApprove;
    }

    public void setIsPreApprove(Integer isPreApprove) {
        this.isPreApprove = isPreApprove;
    }

    public String getAdminPhone() {
        return adminPhone;
    }

    public void setAdminPhone(String adminPhone) {
        this.adminPhone = adminPhone;
    }

    public Integer getOpenType() {
        return openType;
    }

    public void setOpenType(Integer openType) {
        this.openType = openType;
    }

    public Integer getSyncUser() {
        return syncUser;
    }

    public void setSyncUser(Integer syncUser) {
        this.syncUser = syncUser;
    }

    public Integer getSyncOrgDept() {
        return syncOrgDept;
    }

    public void setSyncOrgDept(Integer syncOrgDept) {
        this.syncOrgDept = syncOrgDept;
    }

    public Integer getSyncRank() {
        return syncRank;
    }

    public void setSyncRank(Integer syncRank) {
        this.syncRank = syncRank;
    }

    public Integer getSsoKey() {
        return ssoKey;
    }

    public void setSsoKey(Integer ssoKey) {
        this.ssoKey = ssoKey;
    }

    public Integer getSyncCostInfo() {
        return syncCostInfo;
    }

    public void setSyncCostInfo(Integer syncCostInfo) {
        this.syncCostInfo = syncCostInfo;
    }

    public Integer getFromCityControl() {
        return fromCityControl;
    }

    public void setFromCityControl(Integer fromCityControl) {
        this.fromCityControl = fromCityControl;
    }

    public Integer getBookElasticDay() {
        return bookElasticDay;
    }

    public void setBookElasticDay(Integer bookElasticDay) {
        this.bookElasticDay = bookElasticDay;
    }

    public Integer getRankSecondPass() {
        return rankSecondPass;
    }

    public void setRankSecondPass(Integer rankSecondPass) {
        this.rankSecondPass = rankSecondPass;
    }

    public Integer getNoHotelOneDay() {
        return noHotelOneDay;
    }

    public void setNoHotelOneDay(Integer noHotelOneDay) {
        this.noHotelOneDay = noHotelOneDay;
    }

    public Integer getHotelCityStrategy() {
        return hotelCityStrategy;
    }

    public void setHotelCityStrategy(Integer hotelCityStrategy) {
        this.hotelCityStrategy = hotelCityStrategy;
    }

    public BriChannel getBriChannel(){
        BriChannel briChannel = new BriChannel();
        briChannel.setConfig(JSONObject.toJSONString(this.getConfig()));
        briChannel.setOpenType(this.getOpenType());
        briChannel.setPhone(this.getAdminPhone());
        briChannel.setTenant(this.getTenantId());
        briChannel.setIsPreApprove(this.getIsPreApprove());
        briChannel.setBookElasticDay(this.getBookElasticDay());
        briChannel.setFromCityControl(this.getFromCityControl());
        briChannel.setHotelCityStrategy(this.getHotelCityStrategy());
        briChannel.setNoHotelOneDay(this.getNoHotelOneDay());
        briChannel.setRankSecondPass(this.getRankSecondPass());
        briChannel.setSsoKey(this.getSsoKey());
        briChannel.setSyncCostInfo(this.getSyncCostInfo());
        briChannel.setSyncOrgDept(this.getSyncOrgDept());
        briChannel.setSyncRank(this.getSyncRank());
        briChannel.setSyncUser(this.getSyncUser());
        return briChannel;
    }

    @Override
    public String toString() {
        return "ChannelDTO{" +
                "tenant='" + tenantId + '\'' +
                ", orgs=" + orgs +
                ", channel='" + channel + '\'' +
                ", config=" + config +
                ", isPreApprove=" + isPreApprove +
                ", phone='" + adminPhone + '\'' +
                ", openType=" + openType +
                ", syncUser=" + syncUser +
                ", syncOrgDept=" + syncOrgDept +
                ", syncRank=" + syncRank +
                ", ssoKey=" + ssoKey +
                ", syncCostInfo=" + syncCostInfo +
                ", fromCityControl=" + fromCityControl +
                ", bookElasticDay=" + bookElasticDay +
                ", rankSecondPass=" + rankSecondPass +
                ", noHotelOneDay=" + noHotelOneDay +
                ", hotelCityStrategy=" + hotelCityStrategy +
                '}';
    }
}
